
#include <Eigen/Dense>
#include <cassert>
#include <iostream>
#include <typeinfo>
using namespace std;
using namespace Eigen;
using Eigen::MatrixXd;
int main() {
  MatrixXd m(2, 2);
  m(0, 0) = 1;
  m(1, 0) = 2;
  m(0, 1) = 3;
  m(1, 1) = 4;
  std::cout << m << std::endl;

  MatrixXd mm(2, 2);
  mm << 1, 2, 3, 4;
  cout << "mm = "
       << "\n"
       << mm << "\n";
  VectorXd v(2);
  v << 1, 2;
  cout << "m * v =" << endl << m * v << endl;

  cout << "mm * v =" << endl << mm * v << endl;
  double val[2]{0, 0};
  int v_size = 2;
  Eigen::Map<Eigen::RowVectorXd> v2(val, v_size);
  v2 = m.row(0) * mm;
  cout << v2 << endl;
  cout << typeid(v2).name() << endl;

  cout << val[0] << "  " << val[1] << endl;

  cout << m.col(0).norm() << endl;
  cout << m.col(1).norm() << endl;
  m.row(0) /= 3;
  m.row(1) *= 2;
  cout << m << endl;

  return 0;
}
